Find if number is even or oddΒΆ
Find whether a given number (accept from the user) is even or odd.
Print out an appropriate message to the user.
num = int(input("Enter a number: "))
mod = num % 2
if mod > 0:
print("This is an odd number.")
else:
print("This is an even number.")
Output:
Enter a number: 5
This is an odd number.